package com.lcredu.ajax.servlet;/**
 * @author 黎长容
 * @date 2025-07-03 20:29
 */

import com.lcredu.ajax.service.UserService;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet(name = "UserServlet", urlPatterns = "/UserServlet")
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        String uname = request.getParameter("uname");
        UserService userService = new UserService();
        String userJson = userService.getUserJson(uname);
        response.getWriter().write(userJson);
    }
}